﻿using System;

namespace MyLib.Web {
	/// <summary>
	/// 
	/// </summary>
	public static class HtmlUtility {
		/// <summary>
		/// 
		/// </summary>
		/// <param name="s"></param>
		/// <param name="maxLength"></param>
		/// <returns></returns>
		public static string CutDown(string s, int maxLength = 20) {
			if (maxLength < 8) {
				maxLength = 8;
			}

			if (s == null) {
				return string.Empty;
			} else if (s.Length <= maxLength) {
				return s;
			} else {
				return s.Substring(0, maxLength - 8) + "..." + s.Substring(s.Length - 3);
			}
		}
	} // end of HtmlUtility.
}
